<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
</head>
<body>
    <input type="text" id="input" placeholder="请输入密码">
    <script>
        // 身份证
        // var str = "421083200005252829"
        // var reg = /^42\d{15}[\dx]$/
        // console.log(reg.test(str));
        //密码
        //字母开头 包含至少六位数字
        var r = /^[A-z]+\d{6,}$/
        $("#input").keydown(function(e){
            if(e.keyCode==13){
                var value = $(this).val();
                console.log(value)
                console.log(r.test(value))
            }
        })
    </script>
</body>
</html>